<?php

require ("utilities/utilsAppliTrombi.php") ;

connect() ;

if (empty($_GET['id']))
   $result = executerRequete("SELECT * FROM Eleve WHERE rush>0 AND timeline=0 ORDER BY RAND() LIMIT 1 ;", $GLOBALS['debug']) ;
else
   $result = executerRequete("SELECT * FROM Eleve WHERE id=\"".$_GET['id']."\";", $GLOBALS['debug']) ;
$eleve = mysql_fetch_assoc($result) ;
$result = executerRequete("SELECT * FROM Rush WHERE id=\"".$eleve['rush']."\";", $GLOBALS['debug']) ;
$rush = mysql_fetch_assoc($result) ;

// on nettoie le dossier rush_choix ;
exec ("rm -f rush_choix/*.dv") ;

// deplacement du rush
$nomrush = urlencode($eleve['prenom']." ".$eleve['nom']) ;
$chemin = "rush_choix/".$nomrush.".dv" ;
exec ("cp eleve_trombi/".$rush['lien'].".dv ".$chemin) ;

// Affichage
?>
<a href="index.php?page=listEleves">Retour à la liste des élèves</a><br/>
<center>
<script language="JavaScript">
var dejaTelecharge = false ; // Si on a clique sur le bouton telecharger
var dejaClique=false ; // Si on a modifie l'attribut "Sur la timeline", inutile de demander confirmation
function suivant()
{
   if (dejaTelecharge && !dejaClique && window.confirm("Mettre sur la timeline ?"))
   {
      $.post("ajax/changeTimeline.php", {id:<?= $eleve['id'] ?>, t:1}, function(){
         document.location.reload(true) ;
      }) ;
      return false ;
   }
   return true ;
}
</script>
<div width="100%" style="text-align:right;"><a class="rushSuivant" href="index.php?page=randomRush" onClick="return suivant();" class="suivant"><h2>Suivant</h2></a></div>

<h1><?= $eleve['prenom']." ".$eleve['nom'] ?></h1>

<?
//echo "<div class=\"photo_trombi\" style=\"width:100%;text-align:center;\"><img class=\"phototrombi\" src=\"http://frankiz/trombino.php?image=true&login=".$eleve['login']."&promo=2008\" style=\"height:200px;\"/><br/></div>" ;

$tchecked = "" ;
if ($eleve['timeline']>0) $tchecked = " checked" ;
?>
<center><input type="checkbox" class="timeline" id="timeline" value="1" name="timeline"<?= $tchecked ?>/><label for="timeline"> Sur la timeline</label><br/></center>

<script language="JavaScript">
// Photo trombi originale quand on clique
var original = false ;
$("img.phototrombi").click(function(){
   if (original)
   {
      $("img.phototrombi").attr("src", "http://frankiz/trombino.php?image=true&login=<?= $eleve['login'] ?>&promo=2008") ;
   }
   else
   {
      $("img.phototrombi").attr("src", "http://frankiz/trombino.php?original&image=true&login=<?= $eleve['login'] ?>&promo=2008") ;
   }

}) ;

// Sur la timeline
$("input.timeline").click(function(){
   var checked = 0 ;
   dejaClique = true ;
   if ($(this).attr("checked"))
   { checked = 1 ; }
   $.post("ajax/changeTimeline.php", {id:<?= $eleve['id'] ?>, t:checked}) ;
}) ;
</script>

<div id="player<?= $rush['id'] ?>">
<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="568" height="464" class="apercu">
                <param name="movie" value="player.swf" />
                <param name="allowfullscreen" value="true" />
                <param name="allowscriptaccess" value="always" />
                <param name="flashvars" value="file=eleve_trombi/<?= urlencode($rush['lien']) ?>.flv&image=eleve_trombi/<?= urlencode($rush['lien']) ?>.jpg&volume=0&controlbar=none" />
                <embed
                        type="application/x-shockwave-flash"
                        id="player2"
                        name="player2"
                        src="player.swf"
                        width="568"
                        height="464"
                        allowscriptaccess="always"
                        allowfullscreen="true"
                        flashvars="file=eleve_trombi/<?= urlencode($rush['lien']) ?>.flv&image=eleve_trombi/<?= urlencode($rush['lien']) ?>.jpg&volume=0&controlbar=none"
                />
        </object>
</div>
<a href="<?= $chemin ?>" onClick="dejaTelecharge=true;"><img src="images/icones/telecharger.png"/></a>



</center>
<?php

mysql_close() ;

?>
